package me.heizi.springboot.students.services

//import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
//import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper
//import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper
//import me.heizi.springboot.students.entities.User
//import me.heizi.springboot.students.repositories.UserRepository
//import me.heizi.springboot.students.updateNotNull
//import org.springframework.beans.factory.annotation.Autowired
//import org.springframework.security.core.userdetails.UserDetails
//import org.springframework.security.core.userdetails.UserDetailsPasswordService
//import org.springframework.security.core.userdetails.UserDetailsService
//import org.springframework.stereotype.Service
//import java.lang.IllegalArgumentException
//
//@Service
//class LoginService:UserDetailsPasswordService, UserDetailsService {
//    @Autowired lateinit var users:UserRepository
//
//    override fun updatePassword(user: UserDetails, newPassword: String?): UserDetails {
//        return if(UpdateChainWrapper(users).set("password",newPassword).eq("username",users).update()) {
//            QueryChainWrapper(users).eq("username",user.username).one()
//        } else throw IllegalArgumentException("user not found or sql problem")
//    }
//
//    override fun loadUserByUsername(username: String): UserDetails? {
//        return users.selectByName(username)
//    }
//}